package com.bwie.controller;

import com.bwie.pojo.TbUser;
import com.bwie.service.TbUserService;
import com.bwie.utils.R;
import com.bwie.vo.LoginInfoVo;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * description:
 *
 * @Author caoshuaifeng
 * @Create 2025/3/3 11:51
 * @Version 1.0
 */
@RestController
@RequestMapping("/user/index")
public class IndexController {

    @Autowired
    private TbUserService tbUserService;

    @PostMapping("/login")
    public R login(@RequestBody LoginInfoVo loginInfoVo){
        return tbUserService.login(loginInfoVo);


    }

    @PostMapping("/getUserById/{userId}")
    public R getUserById(@PathVariable("userId") Integer userId){
        return tbUserService.getUserById(userId);

    }
    @PostMapping("/getUserList")
    public R getUserList(@RequestBody PageInfoVo pageInfoVo){
        return tbUserService.getUserList(pageInfoVo);


    }
    @PostMapping("/getSexList")
    public R getSexList(){
    return tbUserService.getSexList();
    }

    @PostMapping("/sendCode/{userMobile}")
    public R sendCode(@PathVariable("userMobile") String userMobile){
        return tbUserService.sendCode(userMobile);

    }

    @PostMapping("/phoneLogin")
    public R phoneLogin(@RequestBody LoginInfoVo loginInfoVo){
      return  tbUserService.phoneLogin(loginInfoVo);

    }
    @PostMapping("/updateStatus/{userId}/{flag}")
    public R updateStatus(@PathVariable("userId") Integer userId,@PathVariable("flag") Integer flag){
       return tbUserService.updateStatus(userId,flag);
    }

    @PostMapping("/updateUser")
    public R updateUser(@RequestBody TbUser tbUser){

        return tbUserService.updateUser(tbUser);
    }

    @PostMapping("/deleteById/{userId}")
    public R deleteById(@PathVariable("userId") Integer userId){
        return tbUserService.deleteById(userId);

    }






}
